<template>
    <div>
        <Card dis-hover :bordered="false" class="ivu-mt">
            <Row :gutter="16" type="flex">
                <Col class="ivu-mb-16">
                <Input 
                    placeholder="请输入姓名/手机号/微信号/唯一身份" 
                    v-model="params.keyword" 
                    clearable 
                    v-width="250"
                    @on-clear="askDatasearch" 
                    @on-enter="askDatasearch" >
                    </Input>
                </Col>
                <Col class="ivu-mb-16">
                <DatePicker 
                    :editable="false" 
                    type="daterange" 
                    v-model="timedate" 
                    :options="options" 
                    placeholder="请选择日期"
                    @on-change="changeDatatime">
                </DatePicker>
                </Col>                                
                <Col class="ivu-mb-16">
                <RadioGroup v-model="timeType" type="button" @on-change="changeTimeType">
                    <Radio label="日" value="1"></Radio>
                    <Radio label="周" value="2"></Radio>
                    <Radio label="月" value="3"></Radio>
                </RadioGroup>
                </Col>
                <Col class="ivu-mb-16">
                <Select placeholder="对话方式" multiple v-model="dialogModes" @on-change="askDatachange">
                    <Option 
                        v-for="item in dialogList" 
                        :key="item.value" 
                        :value="item.value">
                        {{ item.label }}
                    </Option>
                </Select>
                </Col>
                <Col class="ivu-mb-16">
                <Select placeholder="线索状态" multiple  v-model="clueStatus" clearable  @on-open-change="statusOpenChange" @on-change="statusChange">
                    <Option 
                        v-for="item in clueStatusList" 
                        :key="item.value" 
                        :value="item.value">
                        {{ item.label }}
                    </Option>
                </Select>                
                </Col>
                <Col class="ivu-mb-16">
                <TreeSelect v-model="params.channel_id" :data="ChannelList" placeholder="来源渠道" @on-clear="clearChannel" multiple clearable @on-change="askDatachange"/>                
                </Col>
                
                <Col class="ivu-mb-16">
                <Select placeholder="上次联系人" v-model="concatList"  multiple clearable @on-change="askDatachange">
                    <Option 
                        v-for="item in memberList" 
                        :key="item.value" 
                        :value="item.value">
                        {{ item.label }}
                    </Option>
                </Select>
                </Col>
                <!-- <Col style="display: flex;align-items: center;justify-content: center;" class="ivu-mb-16">
                <CheckboxGroup @on-change="checkbox3">
                    <Checkbox label="重复"></Checkbox>
                </CheckboxGroup>                
                </Col>   -->
                <Col>
            <Select
              v-model="params.have_repeat"
              placeholder="全部"
              clearable
              @on-change="checkbox3"
            >
              <Option value="1" label="重复">重复</Option>
              <Option value="2" label="不重复">不重复</Option>
            </Select>
          </Col>
            <Col class="ivu-mb-16">
                <Button type="primary" v-hasC="{
                        name: 'v1-clue-user-export-clue-mobile',
                        flag: 'v1/clue/user/export-clue-mobile',
                }" :loading="exportLoading" @click="exportData">线索导出</Button> 
            </Col> 
            <Col class="ivu-mb-16">
                <Button type="primary" v-if="showDown" @click="downLoadCsv">下载</Button> 
            </Col>                  
            </Row>
            <div class="ivu-clearfix"></div>
            <Table highlight-row ref="table" :columns="columns" :max-height="600" :data="list" :loading="loading" size="small">
                <template slot-scope="{ row }" slot="info">
                    <a @click="openInfo(row)">{{ row.info }}</a>
                </template>
                <template slot-scope="{ row }" slot="contact_time">
                    <span>{{$Date().diff($Date(row.contact_time),'day')}}</span>
                </template>
                <template slot-scope="{ row }" slot="channel">                    
                    <span>{{ row.source_channel }}<span v-if="row.child_source_channel&&row.child_source_channel!='/'">/{{
                    row.child_source_channel}}</span>  </span>
                </template>
                <template slot-scope="{ row }" slot="operation">
                    <a v-hasC="{
                           name: 'v1-clue-user-info',
                           flag: 'v1/clue/user/info',
                       }"
                       @click="openedits(row)" v-if="+row.clue_status_id !== 8 &&+row.patient_user_id==0 ">联系</a>
                    <span class="person" v-if="+row.clue_status_id === 8 &&+row.patient_user_id!==0 ">联系</span>
                    <a  @click="openpatient(row)" v-if="+row.clue_status_id === 9 &&+row.patient_user_id!==0 ">老患者</a>
                    <Divider v-hasC="{
                           name: 'v1-clue-user-info',
                           flag: 'v1/clue/user/info',
                       }"  type="vertical"></Divider>
                    <a v-hasC="{
                           name: 'v1-patient-index-repeat-list8',
                           flag: 'v1/patient/index/repeat-list',
                       }"
                       v-if="row.repeat_type == '1'" @click="repeatData(row)">重复</a>
                </template>
                <template slot-scope="{ row }" slot="dialog_mode">
                    <span>
                        {{ row.dialog_mode === 'E聊' || row.dialog_mode === '快商通'? row.dialog_mode + (row.user_real_name&&row.user_real_name!="/" ? '('  + row.user_real_name + ')' : '') : row.dialog_mode }}
                    </span>
                </template>
                <template slot-scope="{ row }" slot="state">
                    <div v-if="row.clue_status_name">
                        <Badge :status="colors[row.clue_status_name]?colors[row.clue_status_name]:'default'" :text="row.clue_status_name" />
                    </div>
                </template>
            </Table>
            <div class="ivu-mt ivu-text-center">
                <Page show-total show-elevator show-sizer :total="total" :current.sync="params.page"
                      :page-size="params.pageSize" :page-size-opts="pageOpts" @on-change="changepage"
                      @on-page-size-change="changepageSize" ></Page>
            </div>
        </Card>
        <!--线索弹框-->
        <Modal ref="contact" title="联系" v-model="showedit" transfer :styles="{'z-index': 1500}" :mask-closable="false" width="1100"
               @on-cancel="canceledit('formItem')">
            <Row>
                <Col span="8">                           
               
                <Tabs :animated="false" name="children" value="name1" @on-click="audioplays()">
                    <TabPane label="沟通记录" name="name1" tab="children">
                        <div v-if="infoData['type']==1">
                            <div v-if="infoData['list'].length">
                                <div style="max-height: 500px; overflow: auto;">
                                    <Scroll v-if="!isLast" :on-reach-bottom="handleReachBottom" :height="500" :distance-to-edge="[1,1]">  
                                        <template v-for="(item, index) in infoData['list']">                                        
                                            <div :key="index" style="margin-top:10px">
                                                <div style="margin-bottom: 6px;font-size:13px;color:#a7a3a3">
                                                    <span>{{
                                                        item.sender_type === "0"
                                                            ? "客服 - " +
                                                                (item.user_real_name
                                                                    ? item.user_real_name
                                                                    : item.from_id)
                                                            : "患者"
                                                    }}</span>
                                                    <span style="margin-left:30px">{{
                                                        item.receive_time
                                                    }}</span>
                                                </div>
                                                <img @click="seeBIg(item.message)" style="width: 100px;object-fit: cover;"
                                                     v-if="item.message.startsWith('https://')" :src=" item.message" alt="">
                                                <div v-else style="font-weight:600;width:300px;word-break:break-all ">{{
                                                    item.message
                                                }}</div>
                                        
                                            </div>
                                        </template>
                                        <div v-if="isLast" style="display: flex;align-items: center;justify-content: center;color: #aaa;">到底啦~</div>
                                    </Scroll>
                                    <Scroll v-else  :height="500" :distance-to-edge="[1,1]">  
                                        <template v-for="(item, index) in infoData['list']">                                        
                                            <div :key="index" style="margin-top:10px">
                                                <div style="margin-bottom: 6px;font-size:13px;color:#a7a3a3">
                                                    <span>{{
                                                        item.sender_type === "0"
                                                            ? "客服 - " +
                                                                (item.user_real_name
                                                                    ? item.user_real_name
                                                                    : item.from_id)
                                                            : "患者"
                                                    }}</span>
                                                    <span style="margin-left:30px">{{
                                                        item.receive_time
                                                    }}</span>
                                                </div>
                                                <img @click="seeBIg(item.message)" style="width: 100px;object-fit: cover;"
                                                     v-if="item.message.startsWith('https://')" :src=" item.message" alt="">
                                                <div v-else style="font-weight:600;width:300px;word-break:break-all ">{{
                                                    item.message
                                                }}</div>
                                        
                                            </div>
                                        </template>
                                        <div v-if="isLast" style="display: flex;align-items: center;justify-content: center;color: #aaa;">到底啦~</div>
                                    </Scroll>
                                </div>                       
                            </div>
                        </div>                    
                        <div v-else>{{infoData['message']}}</div>
                    </TabPane>
                    <TabPane label="联系记录" name="name2"  tab="children">
                        <Timeline
                            class="ivu-pt-16"
                            style="max-height: 590px; overflow: auto"
                            v-if="data.length > 0"
                        >
                            <TimelineItem v-for="(item, index) in data" :key="index">
                                <template v-if="item.contact_type=='log'">
                                    <p class="time">{{ item.created_at }}</p>
                                    <p class="content">{{ item.content }}</p>
                                    <p class="consultant">
                                        <span class="c-inr ivu-mr-8">{{ item.name }}</span>
                                        <Badge :status="colors[item.status_name]?colors[item.status_name]:'default'" :text="item.status_name" v-if="item.status_name"></Badge>
                                    </p>
                                </template>
                                <template v-if="item.contact_type=='call'" >
                                    <p class="time">{{ item.created_at }}</p>
                                    <p class="content ivu-mt-8" > 
                                        <audio :id="`audio-${index}`" v-if="item.file_url" controls :src="item.file_url"
                                               @play="audioplays(item.speed, index)"></audio>
                                    <div v-if="item.file_url != ''" >
                                        播放倍速：
                                        <RadioGroup v-model="item.speed" @on-change="changeaudio(item.speed, index)">
                                            <Radio :label="items.id" v-for="items in RadioGroup" :key="items.id">{{
                                                items.name
                                            }}</Radio>
                                        </RadioGroup>
                                    </div>
                                    </p>
                                    <p class="consultant ivu-mt-8">
                                        <span>{{item.departmentType}}</span>
                                        <span class="c-inr ivu-ml-8 ivu-mr-8">{{ item.nickname }}</span>
                                        <Badge status="processing" text="呼入"
                                               v-if="+item.call_type===1" class="ivu-mr-8"></Badge>
                                        <Badge class="ivu-mr-8" status="warning" v-if="+item.call_type===2"
                                               text="呼出"></Badge>
                                        <span class="ivu-mr-8" v-if="item.long_time">{{ item.long_time }}秒</span>
                                        <span v-if="+item.is_call===0">未拨通</span>
                                        <span v-else>已拨通</span>
                                    </p>
                                </template>
                            </TimelineItem>
                        </Timeline>
                    </TabPane>
                </Tabs>
                    <!-- <template #title>沟通记录</template>
                    <div v-if="infoData['type']==1">
                        <div v-if="infoData['list'].length">
                            <div style="max-height: 500px; overflow: auto;">
                                <Scroll v-if="!isLast" :on-reach-bottom="handleReachBottom" :height="500" :distance-to-edge="[1,1]">  
                                    <template v-for="(item, index) in infoData['list']">                                        
                                        <div :key="index" style="margin-top:10px">
                                            <div style="margin-bottom: 6px;font-size:13px;color:#a7a3a3">
                                                <span>{{
                                                    item.sender_type === "0"
                                                        ? "客服 - " +
                                                            (item.user_real_name
                                                                ? item.user_real_name
                                                                : item.from_id)
                                                        : "患者"
                                                }}</span>
                                                <span style="margin-left:30px">{{
                                                    item.receive_time
                                                }}</span>
                                            </div>
                                            <img @click="seeBIg(item.message)" style="width: 100px;object-fit: cover;"
                                                 v-if="item.message.startsWith('https://')" :src=" item.message" alt="">
                                            <div v-else style="font-weight:600;width:300px;word-break:break-all ">{{
                                                item.message
                                            }}</div>
                                        
                                        </div>
                                    </template>
                                    <div v-if="isLast" style="display: flex;align-items: center;justify-content: center;color: #aaa;">到底啦~</div>
                                </Scroll>
                                <Scroll v-else  :height="500" :distance-to-edge="[1,1]">  
                                    <template v-for="(item, index) in infoData['list']">                                        
                                        <div :key="index" style="margin-top:10px">
                                            <div style="margin-bottom: 6px;font-size:13px;color:#a7a3a3">
                                                <span>{{
                                                    item.sender_type === "0"
                                                        ? "客服 - " +
                                                            (item.user_real_name
                                                                ? item.user_real_name
                                                                : item.from_id)
                                                        : "患者"
                                                }}</span>
                                                <span style="margin-left:30px">{{
                                                    item.receive_time
                                                }}</span>
                                            </div>
                                            <img @click="seeBIg(item.message)" style="width: 100px;object-fit: cover;"
                                                 v-if="item.message.startsWith('https://')" :src=" item.message" alt="">
                                            <div v-else style="font-weight:600;width:300px;word-break:break-all ">{{
                                                item.message
                                            }}</div>
                                        
                                        </div>
                                    </template>
                                    <div v-if="isLast" style="display: flex;align-items: center;justify-content: center;color: #aaa;">到底啦~</div>
                                </Scroll>
                            </div>                       
                        </div>
                    </div>                    
                    <div v-else>{{infoData['message']}}</div> -->
                         
                </Col>
                <Col span="16">
                <div style="padding-left: 20px;box-sizing: border-box;border-left: 1px solid #9b9ca0;min-height:100%;">
                    <Form label-position="top" :model="contactData" ref="formItem" :rules="createRuless">
                        <FormItem label="联系结果">
                            <RadioGroup v-model="contactData.clue_status_id" @on-change="changeclue">
                                <Radio :label="item.value" v-for="item in clueStatusList" :key="item.value"
                                       v-if="+item.value !== 9">
                                    <span>{{ item.label }}</span>
                                </Radio>
                            </RadioGroup>
                        </FormItem>
                        <Divider />
                        <FormItem label="联系方式" v-if="contactData.clue_status_id == 7"  prop="contact_type">
                            <RadioGroup v-model="contactData.contact_type">
                                <Radio label="1"><span>微信</span></Radio>
                                <Radio label="2"><span>电话</span></Radio>
                                <Radio label="3"><span>其他</span></Radio>
                            </RadioGroup>
                        </FormItem>
                        <template v-if="contactData.clue_status_id === '8'">
                            <Row :gutter="24">
                                <Col span="5">
                                <FormItem label="姓名">
                                    <Input v-model="contactData.userName" placeholder="请输入姓名" ></Input>
                                </FormItem>
                                </Col>
                                <Col span="6">
                                <FormItem label="性别">
                                    <RadioGroup v-model="contactData.sex">
                                        <Radio :label="0">未知</Radio>
                                        <Radio :label="1">男</Radio>
                                        <Radio :label="2">女</Radio>
                                    </RadioGroup>
                                </FormItem>
                                </Col>
                                <Col span="3">
                                <FormItem label="年龄" prop="age">
                                    <InputNumber :max="100" :min="1" v-model="contactData.age"></InputNumber>
                                </FormItem>
                                </Col>
                                <Col span="5">
                                <FormItem label="手机号" prop="mobile">
                                    <Input v-model="contactData.mobile"
                                           @on-keyup="contactData.mobile=contactData.mobile.replace(/\s+|[\r\n]/g,'')"
                                           @on-blur="
                                               telrepeat(contactData.mobile)
                                           " placeholder="请输入手机号" ></Input>
                                    <div style="color:#ff9900;font-size:18px" v-if="patientStatus">！老患者到诊</div>
                                </FormItem>
                                </Col>
                                <Col span="5">
                                <FormItem label="微信号">
                                    <Input v-model="contactData.weChartNum"
                                           @on-keyup="contactData.weChartNum=contactData.weChartNum.replace(/\s+|[\r\n]/g,'')"
                                           @on-blur="WXrepeat(contactData.weChartNum)" placeholder="请输入微信号" ></Input>
                                </FormItem>
                                </Col>
                            </Row>
                            
                            <Row :gutter="24">
                                <Col span="6">
                                <FormItem label="病种" prop="diseases">
                                    <TreeSelect v-model="contactData.diseases" :data="diseasesArr1" @on-change="changeDisease"/>
                                </FormItem>
                                </Col>
                                <Col span="10">
                                <FormItem label="部位" prop="bodyPart" :rules="bodyPartRule">
                                    <TreeSelect :max-tag-count="2" v-model="contactData.bodyPart" :data="postList"
                                                clearable multiple ></TreeSelect>
                                </FormItem>
                                </Col>
                                <Col span="8">
                                <FormItem label="城市" required>
                                    <jgcheckcity ref="checkcity" @cityvalue="cityvalue" v-model="city_id" :name="`grap`"></jgcheckcity>
                                </FormItem>
                                </Col>
                            </Row>
                            <Row :gutter="24">
                                
                                <Col span="5">
                                <FormItem label="患者状态" prop="patientStatus">
                                    <Select placeholder="请选择" v-model="contactData.patientStatus"  @on-change="changeStatus" clearable>
                                        <Option v-for="item in patientStatusArr" :value="item.value" :disabled="
                                            +item.is_select === 0
                                        " :key="item.value">{{ item.label }}</Option>
                                    </Select>
                                </FormItem>
                                </Col>
                                <FormItem label="部门标签" prop="departmentTag" class="ivu-mr-16">
                                    <Select placeholder="请选择" multiple v-model="contactData.departmentTag" clearable>
                                        <Option v-for="item in departmentTagList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                                    </Select>
                                </FormItem>
                                <template v-if="contactData.patientStatus === '2' || contactData.patientStatus === '1' || contactData.patientStatus === '33'|| contactData.patientStatus === '42' || contactData.patientStatus === '39'">
                                    <FormItem label="下次回访时间" prop="day">
                                        <Row :gutter="16" type="flex">
                                            <Col>
                                            <InputNumber :formatter="$inputday" :step="1" :min="0"
                                                         v-model.number="contactData.day" @on-change="
                                                             blurday(contactData.day)
                                                         ">
                                            </InputNumber>
                                            </Col>
                                            <Col>天后</Col>
                                            <Col>
                                            <DatePicker :editable="false" :options="optionss" type="date"
                                                        v-model="DatePicker" @on-change="
                                                            changeday(DatePicker)
                                                        " placeholder="请输入回访时间">
                                            </DatePicker>
                                            </Col>
                                        </Row>
                                    </FormItem>
                                </template>                                
                            </Row>
                            <Row>
                                <template v-if="contactData.patientStatus === '1'">
                                    <FormItem label="预到时间" prop="day1">
                                        <Row :gutter="16" type="flex">
                                            <Col>
                                            <InputNumber :formatter="$inputday" :step="1" :min="0" v-model.number="
                                                contactData.day1
                                            " @on-change="
                                                blurday1(contactData.day1)
                                            ">
                                            </InputNumber>
                                            </Col>
                                            <Col>天后</Col>
                                            <Col>
                                            <DatePicker :editable="false" :options="optionss" type="date"
                                                        v-model="DatePicker1" @on-change="
                                                            changeday1(DatePicker1)
                                                        " placeholder="请输入预约时间">
                                            </DatePicker>
                                            </Col>
                                        </Row>
                                    </FormItem>
                                </template>
                            </Row>
                            
                        </template>
                        <FormItem label="备注" prop="remark" :rules="remarkRule" v-if="contactData.clue_status_id !=28">
                            <Input type="textarea" placeholder="请备注原因" v-model="contactData.remark" @on-blur="saveText"
                                   :autosize="{ minRows: 2, maxRows: 8 }"></Input>   
                        </FormItem>
                    </Form>
                </div>
                </Col>
            </Row>
            <div slot="footer">
                <Button @click="canceledit('formItem')">取消</Button>
                <Button :loading="subloading" type="primary" @click="handlesearch('formItem')">确定</Button>
            </div>
        </Modal>

        <Modal title="重复数据" :mask-closable="false" footer-hide :width="80" v-model="repeatDatas" :draggable="true">
            <Table :max-height="400" :columns="repeatColumns" :data="repeatDataList" :loading="graploading">
                <template slot="user_name" slot-scope="{ row }">
                    <span>{{ row.user_name }}</span>
                    <span>{{
                        row.gender === "0"
                            ? "未知"
                            : row.gender === "1"
                                ? "女"
                                : "男"
                    }}</span>
                    <span>{{ row.age }}</span>
                </template>
                <template slot="mobile" slot-scope="{ row }">
                    <span :class="row.mobile_repeat==1 ? 'repeatColor' : null">
                        {{ row.mobile }}
                    </span>
                </template>
                <template slot="dialog_mode" slot-scope="{ row }">
                    <span>
                        {{ row.dialog_mode}}
                    </span>
                </template>
                <template slot="wechat_num" slot-scope="{ row }">
                    <span :class="row.wechat_repeat==1 ? 'repeatColor' : null">
                        {{ row.wechat_num }}
                    </span>
                </template>
            </Table>
        </Modal>

        <Modal v-model="imgModel" footer-hide>
            <p slot="header">
                查看大图
            </p>
            <img :src="src" style="width: 100%;object-fit: cover;" >
        </Modal>
        <!-- 老患者 -->
        <Modal v-model="modalstatus" title="老患者" :mask-closable="false"  width="1220" :closable="false" footer-hide	>
            <Table highlight-row ref='table' :columns='patientColumns' :loading='patientLoading' :data='patientData'></Table>
            <div class="ivu-mt-16">
                <Row>
                    <Col span="19">
                    <span style="line-height: 33px;">提示：无归属人老患者转客户时归属人会自动修改为当前操作人。已过归属期的患者可先修改归属人再进行操作。</span>
                    </Col>
                    <Col >
                    <div>
                        <Button @click="modalcancel()">取消</Button>
                        <Button class="ivu-ml-16" :loading="modalloading" type="primary" @click="modalSbmit()">老患者转客户</Button>
                    </div>
                    </Col>
                </Row>
            </div>
        </Modal>
        <Info v-if="openDetail" @cancelDrawer="changeInfo" :openDetail="openDetail" :patientInfo="patientInfo"/>
        <bigimgmodal ref="bigimgmodal"></bigimgmodal> 
    </div>
</template>
<script>
    import {
        gtMessage,
        clueuserinfoNew,
        grapRepeatData,
        infoNew,
        patientindexsearchmobile,
        clueusercontact,
        repeatbaiyou,
        oldpatientInfo,
        cluetoPatient,
        clueLog,
        departmentList,
        clueList,
        exportClue
    } from '@api/jzy';
    import util from '@/libs/util';
    import dayjs from 'dayjs';
    // import jgcheckcity from '@/components/checkcity';
    import bigimgmodal from './bigimgmodal';
    import Info from './info';
import params from '../patientcopy/params';
    export default{
        name:'newClue1',
        components: { bigimgmodal ,Info},
        data(){
            const validateMobile = (rule, value, callback) => {
                if(value === '') {
                    callback();
                }else {
                    let reg = /^\d{10,12}$/;
                    if(reg.test(value)) {
                        callback();
                    }else {
                        callback(new Error('请输入正确的联系号码'));
                    }
                }
            };
            const validateChannel = (rule, value, callback) => {
                if(value === '') {
                    callback(new Error('请选择渠道'));
                }else {
                    callback();
                }
            };
            return {
                memberList: [],
                concatList: [],  
                patientColumns: [
                    {
                        title: '基本信息',
                        key: 'info',
                        width: 170,
                    },
                    {
                        title: '患者状态',
                        key: 'patient_status_name',
                        minWidth: 100,
                    },
                    {
                        title: '归属人',
                        key: 'belong_member_name',
                        minWidth: 100,
                    },
                    {
                        title: '渠道',
                        minWidth: 100,
                        // eslint-disable-next-line no-shadow
                        render: (h,params) => {
                            return h('span',`${params.row.channel_name}/${params.row.subdivided_channels_name}`); 
                        }
                    },
                    {
                        title: '地区',
                        key: 'city_name',
                        minWidth: 100,
                    },
                    {
                        title: '手机号',
                        key: 'mobile',
                        width: 140,
                      
                       
                    },
                    {
                        title: '微信号',
                        key: 'wechat',
                        minWidth: 100,
                        
                    },
                    {
                        title: '最后一次回访日期',
                        key: 'last_callback_time',
                        width: 180,
                    },
                    {
                        title: '创建日期',
                        key: 'created_at',
                        width: 180,
                    },
                ],
                showSecond: false,
                ChannelList: [],
                patientLoading: false,
                modalstatus: false,
                patientData: [],
                modalloading: false,
                isLast: false,
                colors: {
                    新数据: 'processing',
                    未联系上: 'error',
                    转客户: 'success',
                    无效: 'warning',
                    测试: 'default',
                    录错: 'default'
                },
                imgModel: false,
                repeatDatas: false,
                openDetail: false,
                patientInfo: {},
                src: '',
                graploading: false,
                timeType: '周',
                dialogList: [],
                clueStatusList: [],
                timedate: [],
                options: {
                    disabledDate(date) {
                        return date && date.valueOf() > Date.now();
                    }
                },    
                dialogModes: [],       
                clueStatus: [],              
                columns: [
                    { title: '基本信息', slot: 'info', fixed: 'left', width: 150 },
                    { title: '地区',tooltip: true, key: 'region', width: 100 },
                    { title: '手机号', key: 'mobile', width: 110},
                    { title: '微信号', key: 'wechat_num', width: 160},
                    { title: '线索状态', slot: 'state', width: 100},
                    { title: '对话方式', slot: 'dialog_mode', width: 100 },                    
                    { title: '渠道', slot: 'channel', width: 160 },
                     { title: '咨询备注', key: 'advisory_remark', minWidth: 120, ellipsis: true, tooltip: true},
                    { title: '录入人', key: 'user_real_name', width: 100},
                    { title: '搜索词', key: 'search_key', width: 120,ellipsis: true, tooltip: true},
                    { title: '关键词', key: 'keyword', width: 120,ellipsis: true, tooltip: true},
                    { title: '来源备注', key: 'source_remark',width: 130,ellipsis: true,tooltip: true},
                    { title: '来源账号', key: 'contact_num', width: 130,ellipsis: true, tooltip: true},                   
                    { title: '联系人', key: 'contact_name', minWidth: 120, ellipsis: true, tooltip: true},
                    { title: '唯一身份', key: 'visitor_uid', minWidth: 150},
                    { title: '来源页', key: 'source_page', width: 130,ellipsis: true, tooltip: true},
                    { title: '创建日期', key: 'created_at',fixed: 'right', width: 150 },
                    { title: '操作', slot: 'operation', fixed: 'right',width: 120}
                ],                
                pageOpts: [10, 15, 20, 30, 50], // 分页每页数量
                list:[],
                loading:false,
                params: {
                    keyword: '',
                    page: 1,
                    pageSize: 10,
                    start_date: dayjs(new Date()).format('YYYY-MM-DD'),
                    end_date: dayjs(new Date()).format('YYYY-MM-DD'),                   
                    clue_status_id: '',
                    dialog_mode_id: '',
                    channel_id: [], 
                    contact_id: '',
                    have_repeat: 0,              
                },
                total:0,
                repeatDataList: [],
                showedit: false,
                infoData: {},
                RadioGroup: [
                    { id: 0.5, name: '0.5' },
                    { id: 0.75, name: '0.75' },
                    { id: 1, name: '1.0' },
                    { id: 1.5, name: '1.5' },
                    { id: 1.75, name: '1.75' },
                    { id: 2, name: '2.0' }
                ],
                repeatInfo: {},
                repeatColumns: Object.freeze([
                    {
                        title: '基本信息',
                        slot: 'user_name',
                        width: 400
                    },
                    {
                        title: '手机号',
                        slot: 'mobile',
                        width: 140
                    },
                    {
                        title: '微信',
                        slot: 'wechat_num',
                        minWidth: 120
                    },
                    {
                        title: '录入人员',
                        key: 'realname',
                        minWidth: 100
                    },
                    {
                        title: '录入时间',
                        key: 'created_at',
                        width: 180
                    }
                ]),
                audioindex: null,
                audioplay: null,
                name: 'name1',
                timeButton: 1,
                firstTime: true,
                contactData: {
                    id: undefined,
                    clue_status_id: '8',
                    remark: '',
                    mobile: '',
                    bodyPart: [],
                    weChartNum: '',
                    day: null,
                    day1: null,
                    type: 1,
                    userName: '',
                    contact_type: '',
                    channel_id: '',
                    subdivided_channels_id: '',
                    age: 0,
                    birthday: '',
                    sex: '',
                    city_id: '',
                    oneDiseases: '',
                    twoDiseases: '',
                    patientStatus: '2',
                    diseases: '',
                    departmentTag: []
                },                
                city_id: [],
                createRuless: {
                    mobile: [{ validator: validateMobile, trigger: 'blur' }],
                    contact_type: [
                        {
                            required: true,
                            message: '请选中联系方式'
                        }
                    ],
                    age: [
                        {
                            required: true,
                            message: '请填写年龄',
                            type: 'number',
                            trigger: 'blur,change'
                        }
                    ],
                    city_id: [
                        {
                            required: true,
                            message: '请选择城市',
                            trigger: 'change'
                        }
                    ],
                    channel_id: [
                        {
                            required: false,
                            // validator: validateChannel,
                            message: '请选择一级渠道',
                            trigger: 'change,blur'
                        }
                    ],
                    subdivided_channels_id: [
                        {
                            required: false,
                            // validator: validateChannel,
                            message: '请选择二级渠道',
                            trigger: 'change,blur'
                        }
                    ],
                    diseases: [
                        {
                            required: true,
                            message: '请选择病种',
                            trigger: 'change'
                        }
                    ],
                    patientStatus: [
                        {
                            required: true,
                            message: '请选择患者状态',
                            trigger: 'change'
                        }
                    ],
                    day: [
                        {
                            required: true,
                            type: 'number',
                            message: '请输入回访时间',
                            trigger: 'change'
                        }
                    ],
                    day1: [
                        {
                            required: true,
                            type: 'number',
                            message: '请输入预约',
                            trigger: 'change'
                        }
                    ]
                },
                patientStatus: '',
                childchannelshow: true,
                child_source_channel: [],
                diseasesArr2: [],
                diseasesArr1: [],
                patientStatusArr: [],
                postList: [],
                DatePicker: '',
                DatePicker1: '',
                subloading: false,
                optionss: {
                    disabledDate(date) {
                        return (
                            date && date.valueOf() < Date.now() - 24 * 3600 * 1000
                        );
                    }
                },
                patient_user_id: '',
                id: '',
                data: [],
                departmentTagList: [],
                statusOpen: false,
                exportLoading:false,
                showDown:false,
                exportUrl:''
            };
        },
        watch: {
            showedit(){
                if(this.showedit){
                    departmentList({type: 1}).then(res => {
                        this.departmentTagList = res.project_tags;
                    });
                }
            }
        },
        created(){
            this.$bus.$on('getClueList',res=>{
                this.getList();
            })
            this.getList();
            clueuserinfoNew({ id: 0, type: 1 }).then(res => {
                this.dialogList = res.dialog;
                this.clueStatusList = res.clue_status;
                this.ChannelList = res.source_channel;
                this.memberList = res.contact_member;
            });
            this.changeTimeType();
        },
        methods: {
            exportData(){
                this.exportLoading=true
                exportClue(this.params).then(res=>{
                    this.exportUrl=res
                    this.showDown=true
                    this.exportLoading=false
                }).catch(()=>{
                    this.exportLoading=false
                })
            },
            downLoadCsv(){
                let apiBaseURL = this.$Setting.apiBaseURL;
                let urls = `${apiBaseURL}/${this.exportUrl}`;
                window.open(urls);
            },
            changeStatus(){
                this.DatePicker = '';
                this.contactData.day = null;
                this.$refs['formItem'].fields.forEach(item => {
                    if(item.prop == 'day'){
                        item.resetField();
                    }
                });
            },
            handleReachBottom () {
                if(this.infoData.list.length >= this.params.page * this.params.pageSize){
                    this.params.page++;      
                    gtMessage(this.params).then((res) => {
                        this.infoData.list = this.infoData.list.concat(res.list);
                    });
                } else{
                    this.isLast = true;
                    this.$Message.info('到底啦！');
                    return;
                }    
            },
           getList(){
            this.showDown=false
            this.loading = true;   
            clueList(this.params).then((res) => {
                this.list = res.list;
                this.list.forEach(item => {
                   for (let i in item) {
                      item[i] = item[i] ? item[i] : '/';
                   }
                });
                this.total = res.total;
                this.loading = false;             
            });
        },
            askDatasearch(){
                this.timeButton = null;
                this.timeType = '';
                if(this.params.keyword !== '') {
                    if(
                        JSON.stringify(this.timedate) !== JSON.stringify(['', ''])
                    ) {
                        let timer = [
                            dayjs(this.timedate[0]).format('YYYY-MM-DD'),
                            dayjs(this.timedate[1]).format('YYYY-MM-DD')
                        ];
                        this.storage.set('clue-list', timer);
                        this.timedate = ['', ''];
                        this.params.start_date = '';
                        this.params.end_date = '';                        
                    }
                }else {
                    if(
                        JSON.stringify(this.storage.get('clue-list')) !==
                        JSON.stringify(['', ''])
                    ) {
                        this.timedate = this.storage.get('clue-list');
                        this.params.start_date = this.timedate[0];
                        this.params.end_date = this.timedate[1];
                    }
                }
                this.params.page = 1;
                this.params.pageSize = 10;
                this.params.channel_id = [];
                this.dialogModes = [];
                this.clueStatus = [];
                this.params.dialog_mode_id = '';
                this.params.clue_status_id = '';
                this.getList();
            },
            openInfo(info){
                this.openDetail = true;
                this.patientInfo = info;
            },
            changeInfo(){
                this.openDetail = false;
            },
            openedits(info){
                this.$refs['formItem'].resetFields();
                this.storage.set('xremark','');
                this.storage.set('wremark','');
                this.storage.set('zremark','');
                clueLog({ clue_user_id: info.id}).then((res) => {
                    this.data = res;
                });
                this.showedit = true;
                let params = {
                    clue_user_id: '',
                    page: 1,
                    pageSize: 10,
                    channel_id: ''        
                };                
                infoNew({id: info.id,type: 1}).then(res => {
                    this.clueList = res.clue_status;
                    this.postList = res.body_parts_list;
                    if(res.contact.length && res.contact[res.contact.length - 1].status_name === '转客户') {
                        this.contactClue = false;
                        this.$Modal.warning({
                            title: '提示消息',
                            content: '该条线索已被转客户，请处理其它线索',
                            onOk: () => {
                                this.askData();
                            }
                        });
                    }
                    this.contact = res.contact;
                    this.info = res.info;
                    this.contactData.userName = res.info.user_name;
                    this.contactData.sex = res.info.gender;
                    this.contactData.mobile = res.info.mobile;
                    this.contactData.channel_id = res.info.channel_id == 0 ? '' : res.info.channel_id + '';
                    this.contactData.subdivided_channels_id = res.info.subdivided_channels_id == 0 ? '' : res.info.subdivided_channels_id + '';
                    
                    this.contactData.weChartNum = res.info.wechat_num;
                    this.contactData.age = +res.info.age ? +res.info.age : null;
                    this.contactData.birthday = res.info.birthday;
                    this.preBirthday = res.info.age;
                    if(
                        res.default_city &&
                        JSON.stringify(res.default_city) !== '{}'
                    ) {
                        this.optionscity = [
                            {
                                value: res.default_city.city_id,
                                label: res.default_city.city_name
                            }
                        ];
                    }
                    this.diseasesArr1 = res.diseasesNew;
                    this.patientStatusArr = res.patient_status;
                    this.DatePicker = '';
                    for(let item of this.clueList) {
                        if(+item.type === 4) {
                            this.contactData.clue_status_id = item.value;
                        }
                    }
                    this.contactData.id = info.id;
                });
                params.clue_user_id = info.id;
                params.channel_id = info.dialog_mode_id;
                this.params.clue_user_id = info.id;
                // this.params.channel_id = info.dialog_mode_id;
                gtMessage(params).then(res => {
                    this.infoData = res;
                    // console.log(this.infoData,' this.infoData');
                });
            },
            repeatData(info){
                this.repeatDatas = true;
                this.graploading = true;
                grapRepeatData({
                    id: info.id
                }).then(res => {
                    this.repeatDataList = res.list;
                    this.repeatInfo = res.info;
                    this.graploading = false;
                });
            },
            changeDatatime(){
                this.timeType = '';
                this.askDatatime();
            },
            askDatatime() {
                this.timeButton = null;
                this.params.start_date = this.timedate[0] ? dayjs(this.timedate[0]).format('YYYY-MM-DD') : '';
                this.params.end_date = this.timedate[1] ? dayjs(this.timedate[1]).format('YYYY-MM-DD') : '';
                let timer = ['', ''];
                if(JSON.stringify(this.timedate) !== JSON.stringify(['', ''])) {
                    timer = [
                        dayjs(this.timedate[0]).format('YYYY-MM-DD'),
                        dayjs(this.timedate[1]).format('YYYY-MM-DD')
                    ];
                }
                this.storage.set('clue-list', timer);
                this.getList();
            },
            changeTimeType(){
                const date = new Date();   
                if(this.timeType == '日'){
                    this.timedate = [date,date];
                }else if(this.timeType == '周'){
                    let before = date.getTime() - 7 * 86400 * 1000;         
                    let beforeDate = new Date(before);
                    this.timedate = [beforeDate,date];
                }else if(this.timeType == '月'){
                    let year = date.getFullYear();  
                    let month = date.getMonth() + 1;
                    let monthDate = new Date(year + '-' + month + '-1');
                    this.timedate = [monthDate,date];                 
                }
                this.askDatatime();
            },
            statusChange(){
                if(!this.statusOpen){
                    this.askDatachange();
                }                
            },
            statusOpenChange(e){
                this.statusOpen = e;
                if(!e){
                    this.askDatachange();
                }
            },
            clearChannel(){
                this.params.channel_id = [];
                this.askDatachange();
            },
            askDatachange(){
                if(this.clueStatus.includes('7')){
                    this.columns = [
                        { title: '基本信息', slot: 'info', fixed: 'left', width: 150 },
                        { title: '地区',tooltip: true, key: 'region', width: 100 },
                        { title: '手机号', key: 'mobile', width: 110},
                        { title: '微信号', key: 'wechat_num', width: 160},
                        { title: '线索状态', slot: 'state', width: 100},
                        { title: '未联系上次数', key: 'uncontacted_count', width: 140 },
                        { title: '最后一次联系时间', key: 'updated_at', width: 160 },
                        { title: '对话方式', slot: 'dialog_mode', width: 100 },    
                        { title: '渠道', slot: 'channel', width: 160 },
                        { title: '咨询备注', key: 'advisory_remark', minWidth: 120, ellipsis: true, tooltip: true},
                        { title: '录入人', key: 'user_real_name', width: 100},
                        { title: '搜索词', key: 'search_key', width: 120,ellipsis: true, tooltip: true},
                        { title: '关键词', key: 'keyword', width: 120,ellipsis: true, tooltip: true},
                        { title: '来源备注', key: 'source_remark',width: 130,ellipsis: true,tooltip: true},
                        { title: '来源账号', key: 'contact_num', width: 130,ellipsis: true, tooltip: true},
                        { title: '联系人', key: 'contact_name', minWidth: 120, ellipsis: true, tooltip: true},
                        { title: '唯一身份', key: 'visitor_uid', minWidth: 150},
                        { title: '来源页', key: 'source_page', width: 130,ellipsis: true, tooltip: true},                        
                        { title: '创建日期', key: 'created_at',fixed: 'right', width: 150 },
                        { title: '操作', slot: 'operation', fixed: 'right', width: 120}
                    ];
                }else{
                    this.columns = [
                        { title: '基本信息', slot: 'info', fixed: 'left', width: 150 },
                        { title: '地区',tooltip: true, key: 'region', width: 100 },
                        { title: '手机号', key: 'mobile', width: 110},
                        { title: '微信号', key: 'wechat_num', width: 160},
                        { title: '线索状态', slot: 'state', width: 100},
                        { title: '对话方式', slot: 'dialog_mode', width: 100 },
                        { title: '渠道', slot: 'channel', width: 160 },
                        { title: '咨询备注', key: 'advisory_remark', minWidth: 120, ellipsis: true, tooltip: true},
                        { title: '录入人', key: 'user_real_name', width: 100},
                        { title: '搜索词', key: 'search_key', width: 120,ellipsis: true, tooltip: true},
                        { title: '关键词', key: 'keyword', width: 120,ellipsis: true, tooltip: true},
                        { title: '来源备注', key: 'source_remark',width: 130,ellipsis: true,tooltip: true},
                        { title: '来源账号', key: 'contact_num', width: 130,ellipsis: true, tooltip: true},
                        { title: '联系人', key: 'contact_name', minWidth: 120, ellipsis: true, tooltip: true},
                        { title: '唯一身份', key: 'visitor_uid', minWidth: 150},
                        { title: '来源页', key: 'source_page', width: 130,ellipsis: true, tooltip: true},
                        { title: '创建日期', key: 'created_at',fixed: 'right', width: 150 },
                        { title: '操作', slot: 'operation', fixed: 'right', width: 120}
                    ];
                } 
                this.params.clue_status_id = this.clueStatus.join(',');
                this.params.dialog_mode_id = this.dialogModes.join(',');
                this.params.contact_id = this.concatList.join(',');
                this.params.page;
                this.params.page = 1;
                this.getList();
            },
            checkbox3(e) {
                // this.timedate = ['', ''];
                // this.timeButton = null;
                this.params.page = 1;
                // this.params.have_repeat = e.length;
                // this.params.start_date = '';
                // this.params.end_date = '';
                this.getList();
            },
            changepage(e){
                this.params.page = e;
                this.getList();
            },
            changepageSize(e){
                this.params.pageSize = e;
                this.getList();
            },
            saveText(){
                if(this.contactData.clue_status_id == 6){
                    this.storage.set('xremark',this.contactData.remark);
                }else if(this.contactData.clue_status_id == 7){
                    this.storage.set('wremark',this.contactData.remark);
                }else if(this.contactData.clue_status_id == 8){
                    this.storage.set('zremark',this.contactData.remark);
                }
            },

             canceledit(name) {
                // this.params.page = 1;
                // this.params.pageSize = 10;
                this.isLast = false;
                if(name) this.$refs[name].resetFields();
                if(this.eChartPage) {
                    this.eChartPage = 1;
                }
                this.audioplays()
                this.showedit = false;
                this.paramscancel();
            },
            changeDisease(e){    
                this.contactData.oneDiseases = '';        
                this.diseasesArr1.forEach(element => {
                    element.children.forEach(item => {
                      if(item.value == e){
                          this.contactData.oneDiseases = element.value;
                          this.contactData.twoDiseases = e;
                      }
                   });                   
                });
                if(this.contactData.oneDiseases == ''){
                    this.contactData.oneDiseases = e;
                    this.contactData.twoDiseases = '';
                }
            },
            changeaudio(speed, id) {
                if(this.audioindex === id) {
                    this.audioplay.playbackRate = speed;
                }
            },
            audioplays(speed, id) {
                if(this.audioplay) {
                    if(this.audioindex !== id) {
                        this.audioplay.pause();
                        this.audioplay = null;
                    }
                }
            
                this.audioindex = id;
                this.audioplay = document.getElementById(`audio-${id}`);
                if(speed){
                    this.audioplay.playbackRate = speed;
                }
                
            },
            blurday(num) {
                this.DatePicker = this.$blurday(num);
            },
            changeday(date) {
                this.contactData.day = this.$changeday(date);
            },
            changeday1(date) {
                this.contactData.day1 = this.$changeday(date);
            },            
            changeclue(e) {   
                for (let item of this.$refs.formItem.fields) {
                    if (item.prop === 'remark') {
                        item.resetField();
                        break;
                    }
                }
                if(this.contactData.clue_status_id == 6){
                  this.contactData.remark = this.storage.get('xremark');
                }else if(this.contactData.clue_status_id == 7){
                    this.contactData.remark = this.storage.get('wremark');
                }else if(this.contactData.clue_status_id == 8){
                    this.contactData.remark = this.storage.get('zremark');
                }
                for(let item of this.clueStatusList) {
                    if(e === item.value) {
                        if(+item.value === 8) this.contactDatas = true;
                        else this.contactDatas = false;
                    }
                }
            },
            telrepeat(data) {
                let config = {
                    id: this.contactData.id === undefined ? 0 : this.contactData.id,
                    mobile: data
                };
                patientindexsearchmobile(config).then(res => {
                    if(+res.result === 1) {
                        this.$Message.error({
                            duration: 2.5,
                            content: '该手机号码已存在'
                        });
                    }
                });
                repeatbaiyou({mobile: data}).then(res => {
                    this.patientStatus = res;
                });
            },
            WXrepeat(data) {
                let config = {
                    id: this.contactData.id === undefined ? 0 : this.contactData.id,
                    wechat_id: data
                };

                patientindexsearchmobile(config).then(res => {
                    if(+res.result === 2) {
                        this.$Message.error({
                            duration: 2.5,
                            content: '该微信号已存在'
                        });
                    }
                });
            },
            cityvalue(city) {
                this.city_id = city;
                this.contactData.city_id = city.join(',');
                // this.askData();
            },
            blurday1(num) {
                this.DatePicker1 = this.$blurday(num);
            },
            handlesearch(name) {
                this.$refs[name].validate(valid => {
                    if(valid) {                        
                        if(this.contactData.clue_status_id === '8') {
                            let config = {
                                id: this.contactData.id === undefined ? 0 : this.contactData.id,
                                mobile: this.contactData.mobile,
                                wechat_id: this.contactData.weChartNum
                            };
                            if(!this.contactData.city_id){
                                this.$Message.warning('城市不能为空');
                                return;
                            }
                            patientindexsearchmobile(config).then(res => {
                                if(+res.result === 1) {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>该手机号码已存在，是否继续录入?</p>',
                                        onOk: () => {
                                            this.submitedit(name);
                                        },
                                        onCancel: () => {
                                            this.remarksloading = false;
                                        }
                                    });
                                }else if(+res.result === 2) {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>该微信号已存在，是否继续录入?</p>',
                                        onOk: () => {
                                            this.submitedit(name);
                                        },
                                        onCancel: () => {
                                            this.remarksloading = false;
                                        }
                                    });
                                }else if(+res.result === 3) {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>该手机号/微信号已存在，是否继续录入?</p>',
                                        onOk: () => {
                                            this.submitedit(name);
                                        },
                                        onCancel: () => {
                                            this.remarksloading = false;
                                        }
                                    });
                                }else {
                                    this.submitedit(name);
                                }
                            });
                        }else {                            
                            this.submitedit(name);
                        }
                    }
                });
            },
            submitedit(name) {                
                if(name) {
                    this.$refs[name].validate(valid => {
                        if(valid) {
                            this.submitedits(name);
                        }
                    });
                }else {
                    this.submitedits(name);
                }
            },
            submitedits(name) {               
                let config = this.paramssubmit();                
                if(config) {
                    this.subloading = true;
                    clueusercontact(config)
                        .then(() => {
                            this.beforsubmit(name);
                            this.subloading = false;
                        })
                        .catch(() => {
                            this.subloading = false;
                    });
                }
            },
            beforsubmit(name) {
                if(name) this.$refs[name].resetFields();
                this.$Message.success('编辑成功');
                this.getList();
                this.paramscancel();
                this.showedit = false;
            },
            paramssubmit() {             
                let config1 = {
                    id: this.contactData.id,
                    clue_status_id: this.contactData.clue_status_id,
                    remark:
                        this.contactData.clue_status_id === '8'
                            ? ''
                            : this.contactData.remark,
                    day:
                        this.contactData.clue_status_id === '8' &&
                        (this.contactData.patientStatus === '2' ||
                        this.contactData.patientStatus === '1' ||
                        this.contactData.patientStatus === '33' ||
                        this.contactData.patientStatus === '42' ||
                        this.contactData.patientStatus === '39')
                            ? parseInt(new Date(this.DatePicker).getTime() / 1000)
                            : '',
                    type: 1,
                    patient_status_id:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.patientStatus
                            : '',
                    user_name:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.userName
                            : '',
                    age:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.age
                            : '',
                    birthday:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.age === this.preBirthday
                                ? this.contactData.birthday
                                    ? this.contactData.birthday
                                    : this.birthdays
                                : this.birthdays
                            : '',
                    patient_diseases_id:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.oneDiseases
                            : '',
                    patient_diseases_child_id:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.twoDiseases
                            : '',
                    patient_remake:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.remark
                            : '',
                    city_id: this.contactData.clue_status_id === '8' ? this.contactData.city_id : '',
                    appointment_day:
                        this.contactData.clue_status_id === '8' &&
                        this.contactData.patientStatus === '1'
                            ? parseInt(new Date(this.DatePicker1).getTime() / 1000)
                            : '',
                    gender:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.sex
                            : '',

                    wechat_num:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.weChartNum
                            : '',
                    mobile:
                        this.contactData.clue_status_id === '8'
                            ? this.contactData.mobile
                            : '',
                    body_parts_id: this.contactData.clue_status_id === '8'
                        ? this.contactData.bodyPart.join(',')
                        : '',
                    contact_type: this.contactData.clue_status_id == 7 ? this.contactData.contact_type : '',
                    channel_id: this.contactData.clue_status_id === '8'
                        ? this.contactData.channel_id
                        : '',
                    subdivided_channels_id: this.contactData.clue_status_id === '8'
                        ? this.contactData.subdivided_channels_id
                        : '',
                    project_ids: this.contactData.clue_status_id === '8' ? this.contactData.departmentTag.join(',') : ''
                };
                
                return config1;
            },
            paramscancel() {
                this.city_id = [];
                this.contactData = {
                    id: undefined,
                    clue_status_id: '8',
                    remark: '',
                    day: null,
                    day1: null,
                    bodyPart: [],
                    type: 1,
                    userName: '',
                    mobile: '',
                    wechat_num: '',
                    channel_id: '',
                    age: 0,
                    contact_type: '',
                    birthday: '',
                    sex: '',
                    city_id: '',
                    oneDiseases: '',
                    twoDiseases: '',
                    patientStatus: '2',
                    diseases: '',
                    departmentTag: [],
                    subdivided_channels_id: '',
                };
                this.DatePicker1 = '';
                this.contactDatas = true;
                this.diseasesArr2 = [];
                this.diseasesArr1 = [];
            },
            seeBIg(item) {
                this.src = item;
                this.imgModel = true;
            },
            openpatient(row){
                this.patient_user_id = row.patient_user_id;
                this.id = row.id;
                this.getoldpatientInfo();
                this.modalstatus = true;
            },
            getoldpatientInfo(){
                oldpatientInfo({patient_user_id: this.patient_user_id}).then(res => {
                    this.patientData = res;
                });
            },
            modalcancel(){
                this.modalstatus = false;
            },
            modalSbmit(){
                this.modalloading = true;
                cluetoPatient({id: this.id}).then(res => {
                    this.$Message.success('老患者转客户成功');
                    this.modalloading = false;
                    this.modalstatus = false;
                    this.getList();
                }).catch(() => {
                    this.modalloading = false;
                });
            }
        },
        computed: {
            remarkRule() {
                if(this.contactData.clue_status_id === '8') {
                    return {
                        required: false,
                        type: 'string',
                        message: '请输入备注原因',
                        trigger: 'blur'
                    };
                }else {
                    return {
                        required: true,
                        type: 'string',
                        message: '请输入备注原因',
                        trigger: 'blur'
                    };
                }
            },           
            bodyPartRule() {
                if(this.contactData.oneDiseases === '1') {
                    return {
                        required: true,
                        validator: (rule, value, callback) => {
                            if(value.length) {
                                callback();
                            }else {
                                callback(new Error('请选择部位'));
                            }
                        },
                        trigger: 'change'
                    };
                }else {
                    return {
                        required: false,
                        type: 'array',
                        trigger: 'change'
                    };
                }
            },
            
        }
        
    };
</script>   
<style scoped>
     .consultant{
      color: #9ea7b4;
    }
/deep/.ivu-modal-mask{
    z-index: 1000 !important;
}
/deep/.ivu-modal-wrap{
    z-index: 1000 !important;
}
    .repeatColor {
        color: red;
    }
    .ivu-radio-group-button .ivu-radio-wrapper-checked{
        background: #2d8cf0;
        color: #fff;
    }
    .ivu-card-shadow,.ivu-card.ivu-card-shadow:hover{
        box-shadow: none;
    }
    .person {
        color: #999;
    }
    /deep/.ivu-table-cell{
        padding-left: 5px;
        padding-right: 5px;
    }
    /* /deep/::-webkit-scrollbar {
      width: 2px;
      height: 2px;
    }
    /deep/ ::-webkit-scrollbar-thumb {
        border-radius: 2px;
        background: #6b7385;
        -webkit-box-shadow: inset 0 0 2px rgb(0 0 0 / 20%);
    }
    /deep/ ::-webkit-scrollbar-track {
      background: rgba(245,247,248,.5);
    } */
</style>